package com.sright.bcard.common.service.share.excel.style;

import org.apache.poi.ss.usermodel.*;

/**
 * 表头样式：白色背景 + 红色文本
 * Created by zh on 2019/7/17.
 */
public class RedWordWithoutBorderHeaderCellStyle implements HeaderCellStyle {

    /* 是否创建表头 */
    public boolean isCreateHeader = true;

    /* 表头行索引 */
    public int headerRowNumber = 0;

    @Override
    public boolean isCreateHeader() {
        return isCreateHeader;
    }

    @Override
    public int getHeaderRowNumber() {
        return headerRowNumber;
    }

    @Override
    public CellStyle getCellStyle(Workbook workbook) {
        CellStyle cellStyle = workbook.createCellStyle();
        //设置居中
        cellStyle.setAlignment(HorizontalAlignment.CENTER); // 居中

        //设置字体
        Font font = workbook.createFont();
        font.setFontName("楷体");
        font.setFontHeightInPoints((short) 12);//设置字体大小
        font.setColor(IndexedColors.RED.getIndex());
        font.setBold(true);
        cellStyle.setFont(font);//选择需要用到的字体格式

        return cellStyle;
    }
}
